﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml.Packaging;
using NUnit.Framework;

namespace OpenPowerPointTest.Helpers
{
    /// <summary>
    /// Tests the relation resolver
    /// </summary>
    /// <remarks><seealso cref="RelationResolver"/></remarks>
    [TestFixture]
    [Category("Unit: Converter")]
    public class RelationResolver
    {
        private PresentationDocument _document;
        private Stream _stream;

        #region Setup/Teardown
        [SetUp]
        public void Setup()
        {
            _stream = new MemoryStream(Presentations.single, true);
            //Theres a problem: Stream not seekable

            _document = PresentationDocument.Open(_stream, false);
        }

        [TearDown]
        public void Teardown()
        {
            _stream.Close();
            _document.Close();
        }
        #endregion

        /// <summary>
        /// Does GetSlideById work?
        /// </summary>
        /// <remarks><seealso cref="OpenPowerPoint.RelationResolver.GetSlideById"/></remarks>
        [Test]
        public void SlideResolve()
        {
            Assert.AreEqual(_document.PresentationPart.SlideParts.ElementAt(0), OpenPowerPoint.RelationResolver.GetSlideById(256, _document.PresentationPart));
        }

        /// <summary>
        /// Does GetMasterSlideById work?
        /// </summary>
        /// <remarks><seealso cref="OpenPowerPoint.RelationResolver.GetSlideMasterById"/> </remarks>
        [Test]
        public void SlideMasterResolve()
        {
            Assert.AreEqual(_document.PresentationPart.SlideMasterParts.ElementAt(0), OpenPowerPoint.RelationResolver.GetSlideMasterById(2147483648, _document.PresentationPart));
        }
    }
}
